import Vue from "vue";
import VueRouter from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "payment",
    component: require("./views/Payment.vue").default
  },
  {
    path: "/confirm",
    name: "confirm",
    component: require("./views/Confirm.vue").default
  }
];

const router = new VueRouter({
  routes,
  scrollBehavior(to, from, pos) {
    return pos || { x: 0, y: 0 };
  }
});

router.beforeEach(async (to, from, next) => {
  NProgress.start();

  next();
});

router.afterEach(() => {
  NProgress.done();
});

export default router;
